package com.tj.collection.service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fqgj.common.utils.*;
import com.fqgj.exception.common.ApplicationException;
import com.fqgj.log.factory.LogFactory;
import com.fqgj.log.interfaces.Log;
import com.tj.collection.service.dto.*;
import com.tj.collection.utils.IndiaMobileUtil;
import org.springframework.stereotype.Component;

import java.util.*;
import java.util.stream.Collectors;

/**
 * Created with IntelliJ IDEA.
 * User: Watson Qiu
 * Date: 2017/03/09
 * Time: 下午4:02
 */
//通讯录接入
@Component
public class ContactApplication {

    private static final Log logger = LogFactory.getLog(ContactApplication.class);

    /**
     * 用户设备信息解析
     *
     * @param contactUrlList
     * @param userName
     * @param mobile
     * @return
     */
    public DeviceContactDataVO loadDeviceContactDataV2(List<String> contactUrlList, String userName, String mobile) {
        List<DeviceContact2VO> contactsTmp = new ArrayList<>();
        List<DeviceContact2VO> contacts = new ArrayList<>();

        logger.info("加载通讯录,mobile:{},contactUrlList:{}", mobile, contactUrlList.toString());

        for (int i = contactUrlList.size() - 1; i >= 0; i--) {
            String url = contactUrlList.get(i);
            String replace = url.replace("http://cashmama-oss-pro.cashmama.in", "https://cashmama-bak.oss-ap-south-1.aliyuncs.com");
            String contentStr = HttpUtil.getPage(replace);
            if (StringUtils.isEmpty(contentStr)) {
                continue;
            }
            try {
                JSONObject j1 = JSON.parseObject(contentStr);
                JSONArray c1 = j1.getJSONArray("contacts");
                List<DeviceContact2VO> d1 = JSON.parseArray(c1.toJSONString(), DeviceContact2VO.class);
                if (d1 != null && d1.size() > 0) {
                    contactsTmp.addAll(d1);
                }
            } catch (Exception e) {
                logger.error("获取通讯录对象失败,mobile:{},url:{}", mobile, url, e);
            }
        }
        for (DeviceContact2VO vo : contactsTmp) {
            boolean has = false;
            for (DeviceContact2VO vo1 : contacts) {
                if (vo1.getPhone() == null) {
                    continue;
                }
                if (vo1.getPhone().equalsIgnoreCase(vo.getPhone())) {
                    has = true;
                    break;
                }
            }
            if (!has) {
                contacts.add(vo);
            }
        }

        JSONObject contactObj = new JSONObject();
        contactObj.put("contacts", contacts);

        DeviceContactDataVO data = null;
        try {
            data = getContactByList(contactObj.toJSONString(), mobile);
        } catch (Exception e) {
            logger.error("通讯录数据解析失败,mobile:{},contactUrl:{}", mobile, contactUrlList.toString(), e);
            throw new ApplicationException("Data parsing failed");
        }

        data.setRealName(userName);
        data.setMobile(mobile);
        return data;
    }


    /**
     * 解析通话记录
     *
     * @param deviceCallVOS 原始oss通话记录信息
     * @return
     */
    private PhoneCallRecordVO getPhoneCallRecordVO(List<DeviceCallVO> deviceCallVOS) {
        //以phone为key 存储
        if (CollectionUtils.isEmpty(deviceCallVOS)) {
            return null;
        }
        //以phone为key 存储
        Map<String, PhoneCallRecordItemVO> callRecordVOMap = new LinkedHashMap<>();
        for (DeviceCallVO deviceCallVO : deviceCallVOS) {
            //跳过信息不完整的记录
            if (!deviceCallVO.isComplete()) {
                continue;
            }
            PhoneCallRecordItemVO phoneCallRecordItemVO = callRecordVOMap.get(deviceCallVO.getPhone());
            //和此号码的首次通话--初始化
            if (null == phoneCallRecordItemVO) {
                phoneCallRecordItemVO = new PhoneCallRecordItemVO(0L, 0, 0, 0);
                phoneCallRecordItemVO.setPhone(deviceCallVO.getPhone());
                phoneCallRecordItemVO.setName(deviceCallVO.getName());
                //调用归属地api 欺诈字库  机构识别api TODO 缺少api
                phoneCallRecordItemVO.setAttribution("");
                phoneCallRecordItemVO.setMechanism("");
                phoneCallRecordItemVO.setAbnormal(0);
            }
            if (phoneCallRecordItemVO.getLastTime() < Long.parseLong(deviceCallVO.getCallTime())) {
                phoneCallRecordItemVO.setLastTime(Long.parseLong(deviceCallVO.getCallTime()));
                phoneCallRecordItemVO.setLastTimeStr(toDateString(deviceCallVO.getCallTime()));
            }
            if ("呼出".equals(deviceCallVO.getCallType())) {
                phoneCallRecordItemVO.setCallOutCount(phoneCallRecordItemVO.getCallOutCount() + 1);
            }
            if ("呼入".equals(deviceCallVO.getCallType())) {
                phoneCallRecordItemVO.setCallInCount(phoneCallRecordItemVO.getCallInCount() + 1);
            }
            phoneCallRecordItemVO.setCallInAndOut(phoneCallRecordItemVO.getCallInCount() + "/" + phoneCallRecordItemVO.getCallOutCount());
            phoneCallRecordItemVO.setTotalCallDuration(phoneCallRecordItemVO.getTotalCallDuration() + Integer.parseInt(deviceCallVO.getCallDuration()));
            callRecordVOMap.put(deviceCallVO.getPhone(), phoneCallRecordItemVO);
        }
        //按照最后通话时间 降序排列
        List<PhoneCallRecordItemVO> phoneCallRecordItemVOS = new ArrayList<>(callRecordVOMap.values());
        phoneCallRecordItemVOS.sort((o1, o2) -> {
            Long lastTime1 = o1.getLastTime();
            Long lastTime2 = o2.getLastTime();
            if (lastTime1 > lastTime2) {
                return -1;
            } else if (lastTime1.equals(lastTime2)) {
                return 0;
            } else {
                return 1;
            }
        });

        PhoneCallRecordVO phoneCallRecordVO = new PhoneCallRecordVO();
        phoneCallRecordVO.setPhoneCallRecordItemVOList(phoneCallRecordItemVOS);
        phoneCallRecordVO.setTotal(deviceCallVOS.size());

        // TODO: 2018/9/10 缺少对应关系API
        phoneCallRecordVO.setAbnormal(0);
        phoneCallRecordVO.setMechanism(0);
        return phoneCallRecordVO;
    }

    /**
     * 短信解析
     *
     * @param deviceCallVOS
     * @return
     */
    private SmsRecordVO getSmsRecordVO(List<DeviceSmsVO> deviceCallVOS) {
        //以phone为key 存储
        if (CollectionUtils.isEmpty(deviceCallVOS)) {
            return null;
        }
//        Map<String, SmsRecordItemVO> smsRecordVOMap = new LinkedHashMap<>();
//        for (DeviceSmsVO deviceSmsVO : deviceCallVOS) {
//
//            SmsRecordItemVO smsRecordItemVO = smsRecordVOMap.get(deviceSmsVO.getPhoneId());
//            //首次通话记录--初始化
//            if (null == smsRecordItemVO) {
//                smsRecordItemVO = new SmsRecordItemVO();
//                smsRecordItemVO.setMobile(deviceSmsVO.getPhoneId());
//                smsRecordItemVO.setName(deviceSmsVO.getName());
//                smsRecordItemVO.setContent(deviceSmsVO.getBody());
//            }
//            if (smsRecordItemVO.getLastTime() != null && smsRecordItemVO.getLastTime() < Long.parseLong(deviceSmsVO.getDataSend())) {
//                smsRecordItemVO.setLastTime(Long.parseLong(deviceSmsVO.getDataSend()));
//            }
//
//            smsRecordVOMap.put(deviceSmsVO.getPhoneId(), smsRecordItemVO);
//        }
//        //按照最后通话时间 降序排列
//        List<SmsRecordItemVO> smsRecordItemVOS = new ArrayList<>(smsRecordVOMap.values());
//        smsRecordItemVOS.sort((o1, o2) -> {
//            Long lastTime1 = o1.getLastTime();
//            Long lastTime2 = o2.getLastTime();
//            if (lastTime1 > lastTime2) {
//                return -1;
//            } else if (lastTime1.equals(lastTime2)) {
//                return 0;
//            } else {
//                return 1;
//            }
//        }

        List<SmsRecordItemVO> smsRecordItemVOS = new ArrayList<>();
        for (DeviceSmsVO deviceSmsVO : deviceCallVOS) {
            SmsRecordItemVO smsRecordItemVO = new SmsRecordItemVO();
            smsRecordItemVO.setMobile(deviceSmsVO.getPhoneId() == null ? deviceSmsVO.getAddress() : deviceSmsVO.getPhoneId());
            smsRecordItemVO.setName(deviceSmsVO.getName() == null ? deviceSmsVO.getAddress() : deviceSmsVO.getAddress());
            smsRecordItemVO.setContent(deviceSmsVO.getBody());
            smsRecordItemVO.setMessageNum("1");
            smsRecordItemVO.setLastTime(DateUtil.getDateTime(new Date(Long.valueOf(deviceSmsVO.getDataSend()))));
            smsRecordItemVOS.add(smsRecordItemVO);
        }

        SmsRecordVO smsRecordVO = new SmsRecordVO();
        smsRecordVO.setSmsRecordItemVOList(smsRecordItemVOS);
        smsRecordVO.setTotal(deviceCallVOS.size());

        return smsRecordVO;
    }


    /**
     * 通讯录集合解析
     *
     * @param content
     * @param mobile
     * @return
     * @throws Exception
     */

    public static void main(String[] args) {
        try {
            String content = "{\"contacts\":[{\"phone\":\"9611824236\",\"name\":\"Brother\"},{\"phone\":\"8792579121\",\"name\":\"Sagar2\"},{\"phone\":\"7483911846\",\"name\":\"Benki Mahadhev\"},{\"phone\":\"9844085221\",\"name\":\"Raju Bhai Bncr\"},{\"phone\":\"6363049414\",\"name\":\"Chethu Bouncer\"},{\"phone\":\"8105265822\",\"name\":\"Madhev Jio\"},{\"phone\":\" 97310 53370\",\"name\":\"Shekar Drs\"},{\"phone\":\" 99451 13426\",\"name\":\"Mahadev Benki\"},{\"phone\":\"9164910476\",\"name\":\"Rocky Bogadhi\"},{\"phone\":\"9739882602\",\"name\":\"Rangswamy\"},{\"phone\":\"9008181503\",\"name\":\"Shasi Boncer\"},{\"phone\":\" 80880 68015\",\"name\":\"Unath Pk\"},{\"phone\":\"9066313198\",\"name\":\"Samarth Sathish Bouncer\"},{\"phone\":\"7795231351\",\"name\":\"Satya\"},{\"phone\":\"8553288786\",\"name\":\"Fazil Bouncer\"},{\"phone\":\"9535622873\",\"name\":\"Prashanth\"},{\"phone\":\"9110254167\",\"name\":\"Bharath m\"},{\"phone\":\"9632649399\",\"name\":\"Hn\"},{\"phone\":\"543216\",\"name\":\"AL friendz chat\"},{\"phone\":\"9844063719\",\"name\":\"Chandra kamu\"},{\"phone\":\"99641 96205\",\"name\":\"Grand pa\"},{\"phone\":\"93421 85672\",\"name\":\"Krisha Reddy Sir\"},{\"phone\":\"6366843679\",\"name\":\"Sangga\"},{\"phone\":\"8050597008\",\"name\":\"Manju Anna Bncr\"},{\"phone\":\"112\",\"name\":\"Distress Number\"},{\"phone\":\"6363599943\",\"name\":\"Chaitanya Checkp\"},{\"phone\":\"9164304099\",\"name\":\"Vikash Bouncer\"},{\"phone\":\" 81971 89187\",\"name\":\"Yashwant Blk\"},{\"phone\":\"198\",\"name\":\"Jio-Complaint Helpline\"},{\"phone\":\"7411561365\",\"name\":\"Akilesh Narayan\"},{\"phone\":\" 91649 10476\",\"name\":\"Rocky Bogadhi\"},{\"phone\":\"6363643583\",\"name\":\"Pavan Check Post 2\"},{\"phone\":\"9380815311\",\"name\":\"Bouncer Kiran Sidharth\"},{\"phone\":\"70226 85798\",\"name\":\"Manja hatasaman\"},{\"phone\":\"9900450283\",\"name\":\"Shivu Bengaluru\"},{\"phone\":\"734973272\",\"name\":\"Santhu t\"},{\"phone\":\"9964650365\",\"name\":\"Kreziby Csmr cr\"},{\"phone\":\"7760588914\",\"name\":\"Raju Dhubai\"},{\"phone\":\"9164983180\",\"name\":\"Mahadev prasadh\"},{\"phone\":\" 74839 11846\",\"name\":\"Benki Mahadhev\"},{\"phone\":\"8296166017\",\"name\":\"Vikas Bouncer Koor\"},{\"phone\":\"7208926906\",\"name\":\"Bhasava Lap\"},{\"phone\":\"9380991899\",\"name\":\"Rahul Andl\"},{\"phone\":\"9880736711\",\"name\":\"2 Chethu\"},{\"phone\":\"55100\",\"name\":\"emergency hotline\"},{\"phone\":\"9845200304\",\"name\":\"Suman Gym\"},{\"phone\":\"102\",\"name\":\"ambulance\"},{\"phone\":\"9035799096\",\"name\":\"Abhishek Narayan\"},{\"phone\":\"9731312730\",\"name\":\"Yes Bank\"},{\"phone\":\"7259589164\",\"name\":\"Rashmi V\"},{\"phone\":\"8150085480\",\"name\":\"Colgate\"},{\"phone\":\" 96118 24236\",\"name\":\"Brother\"},{\"phone\":\"8095741940\",\"name\":\"Jayanth Bouncer Mys\"},{\"phone\":\"7760635807\",\"name\":\"Rp\"},{\"phone\":\" 91106 59585\",\"name\":\"Harsha Bouncer\"},{\"phone\":\"9008907878\",\"name\":\"Ashish Event\"},{\"phone\":\"7022685798\",\"name\":\"Manja hatasaman\"},{\"phone\":\"7026801944\",\"name\":\"Kiranaa G\"},{\"phone\":\"9743213472\",\"name\":\"Nachiketan\"},{\"phone\":\"9902237978\",\"name\":\"Kantha\"},{\"phone\":\"06366247138\",\"name\":\"Dhanu Praju\"},{\"phone\":\"9740431148\",\"name\":\"lankesh j\"},{\"phone\":\"8722764624\",\"name\":\"Punith rajkumar\"},{\"phone\":\"734 891 0967\",\"name\":\"Suheal\"},{\"phone\":\"7659083214\",\"name\":\"Przlee\"},{\"phone\":\"9964196205\",\"name\":\"Grand pa\"},{\"phone\":\"9008073318\",\"name\":\"Venki\"},{\"phone\":\"8105609054\",\"name\":\"Bncr Gunda Mys Prm\"},{\"phone\":\"7353053367\",\"name\":\"Vishwa Vvet\"},{\"phone\":\"9964912335\",\"name\":\"Krishna\"},{\"phone\":\"9206811982\",\"name\":\"Tamma2\"},{\"phone\":\"9663632800\",\"name\":\"Shekhar Puram\"},{\"phone\":\" 70268 68278\",\"name\":\"Pavan Bouncer\"},{\"phone\":\"7996718002\",\"name\":\"Harsha Bilikere\"},{\"phone\":\"8884797594\",\"name\":\"Siddu Bajaj\"},{\"phone\":\"9611552346\",\"name\":\"Sanga\"},{\"phone\":\"87479 52003\",\"name\":\"Bukki Bashkar\"},{\"phone\":\"9901226050\",\"name\":\"Mm\"},{\"phone\":\"7338449244\",\"name\":\"Vignesh\"},{\"phone\":\"9535413560\",\"name\":\"Mahadhev Nayaka\"},{\"phone\":\"9742788104\",\"name\":\"Lohith\"},{\"phone\":\"7760148663\",\"name\":\"Jammu\"},{\"phone\":\"8050303757\",\"name\":\"Prakashannna Gym\"},{\"phone\":\"8904495620\",\"name\":\"Nuthan Blk Adnl\"},{\"phone\":\"8792579121\",\"name\":\"Sagar2\"},{\"phone\":\"99804 33253\",\"name\":\"Prashi Bro Bnsr\"},{\"phone\":\"8050557767\",\"name\":\"Yogi Mys\"},{\"phone\":\"9591544815\",\"name\":\"Swamy D Jenahali\"},{\"phone\":\"9342185672\",\"name\":\"Krisha Reddy Sir\"},{\"phone\":\"9844025563\",\"name\":\"Puni\"},{\"phone\":\"7577855400\",\"name\":\"Jeveeka\"},{\"phone\":\"7026795118\",\"name\":\"Chandu Karthi\"},{\"phone\":\"8197967705\",\"name\":\"Manju bai\"},{\"phone\":\"9611824236\",\"name\":\"Brother\"},{\"phone\":\"7348910967\",\"name\":\"Suheal\"},{\"phone\":\"8105405550\",\"name\":\"Kiran d G\"},{\"phone\":\"7619621242\",\"name\":\"Ravi bond\"},{\"phone\":\" 63668 43679\",\"name\":\"Sangga\"},{\"phone\":\"*321#\",\"name\":\"AL * dial\"},{\"phone\":\"6360435211\",\"name\":\"Karuna\"},{\"phone\":\" 73385 13527\",\"name\":\"Vaibavi\"},{\"phone\":\"9980100100\",\"name\":\"Madhevapa D Y S P\"},{\"phone\":\"8722795196\",\"name\":\"Chethan Cm\"},{\"phone\":\"8971838093\",\"name\":\"Ambu Mys\"},{\"phone\":\"7899882760\",\"name\":\"Harish m\"},{\"phone\":\"7624951495\",\"name\":\"Chandu Dvl\"},{\"phone\":\"7899505035\",\"name\":\"Roopa Athe\"},{\"phone\":\"9632743320\",\"name\":\"Santhosh Tusion\"},{\"phone\":\"9739177808\",\"name\":\"Manu dastikolla\"},{\"phone\":\"91642 27588\",\"name\":\"Bouncer Manoj Rh\"},{\"phone\":\"9686262939\",\"name\":\"Mahesh Mobile\"},{\"phone\":\"8105732830\",\"name\":\"Prashanth Halka\"},{\"phone\":\"9071581653\",\"name\":\"Krezy Bee Customer\"},{\"phone\":\"7348907739\",\"name\":\"Praju\"},{\"phone\":\"9611824236\",\"name\":\"Brother\"},{\"phone\":\"8746814364\",\"name\":\"Madhu\"},{\"phone\":\"9900705406\",\"name\":\"Prajwal Ilv Bnc\"},{\"phone\":\" 94490 72846\",\"name\":\"Praveen Sunder\"},{\"phone\":\"8861694949\",\"name\":\"Chandhu Patel\"},{\"phone\":\"9606721137\",\"name\":\"Shasi Indbulls\"},{\"phone\":\"7090416726\",\"name\":\"S Afuuuu\"},{\"phone\":\"9113883510\",\"name\":\"Suni Blk\"},{\"phone\":\"9164227588\",\"name\":\"Bouncer Manoj Rh\"},{\"phone\":\"8971494986\",\"name\":\"Pradeep sir\"},{\"phone\":\" 70192 55942\",\"name\":\"Suheal Blk\"},{\"phone\":\"9743220841\",\"name\":\"Manu Railway\"},{\"phone\":\"7026264636\",\"name\":\"Kiran Mcm d\"},{\"phone\":\"8892373249\",\"name\":\"Raje M\"},{\"phone\":\"7022244605\",\"name\":\"Sanju Ilv\"},{\"phone\":\"9901452205\",\"name\":\"Bharath batta\"},{\"phone\":\"9986586464\",\"name\":\"Event Mysore\"},{\"phone\":\"543213\",\"name\":\"AL on demand\"},{\"phone\":\"7406533696\",\"name\":\"Sakib\"},{\"phone\":\"8867646665\",\"name\":\"Delip Bai Koplu\"},{\"phone\":\"8970093068\",\"name\":\"Karthik Nayak pb\"},{\"phone\":\" 95380 86785\",\"name\":\"Kiran Bnsr\"},{\"phone\":\"8496989466\",\"name\":\"Balogola cps\"},{\"phone\":\"9663697375\",\"name\":\"Lavanya Ic\"},{\"phone\":\"*325#\",\"name\":\"facebook\"},{\"phone\":\"9845660197\",\"name\":\"Pr\"},{\"phone\":\"9611576880\",\"name\":\"Madhevanna2\"},{\"phone\":\"9845064552\",\"name\":\"HEMANTH ANNA B\"},{\"phone\":\"8722818122\",\"name\":\"Harsha Boncer\"},{\"phone\":\"9394801274\",\"name\":\"Sonali\"},{\"phone\":\"8884144186\",\"name\":\"Impana\"},{\"phone\":\"9632988125\",\"name\":\"Pursotham\"},{\"phone\":\" 97423 42303\",\"name\":\"Raghu Mm\"},{\"phone\":\"7022003950\",\"name\":\"Loan Sanga\"},{\"phone\":\"8151844420\",\"name\":\"420 Manu\"},{\"phone\":\"8073859186\",\"name\":\"Putta\"},{\"phone\":\"9972565018\",\"name\":\"Harish Praju Mm\"},{\"phone\":\"7026587141\",\"name\":\"Mahadev Ms 2\"},{\"phone\":\"8151934533\",\"name\":\"Venki Bouncer\"},{\"phone\":\"9836531076\",\"name\":\"Anna Bounce Mys\"},{\"phone\":\"8553709297\",\"name\":\"Puttu Bro\"},{\"phone\":\"9164012426\",\"name\":\"Netra Inb\"},{\"phone\":\"9739946265\",\"name\":\"Managala Anty\"},{\"phone\":\"7019505954\",\"name\":\"Put Mava 2\"},{\"phone\":\"9071241012\",\"name\":\"manju bhai 2\"},{\"phone\":\"9164536614\",\"name\":\"Chethu Bai Drag\"},{\"phone\":\"7892120101\",\"name\":\"Arun Pk\"},{\"phone\":\" 81055 48664\",\"name\":\"Sachi Mcm\"},{\"phone\":\"8151878020\",\"name\":\"Yogesha vh\"},{\"phone\":\"9901034323\",\"name\":\"Chandranna\"},{\"phone\":\"7349026816\",\"name\":\"Darshan Soppu\"},{\"phone\":\"7975955755\",\"name\":\"Raghu\"},{\"phone\":\" 73381 59829\",\"name\":\"Dj Presly\"},{\"phone\":\"9743054461\",\"name\":\"Sangeetha\"},{\"phone\":\"8618911495\",\"name\":\"Sudha Chikki\"},{\"phone\":\" 78295 61828\",\"name\":\"Sudha Maa\"},{\"phone\":\"7019255942\",\"name\":\"Suheal Blk\"},{\"phone\":\"9964477562\",\"name\":\"Pavitra Medam\"},{\"phone\":\" 80505 57767\",\"name\":\"Yogi Mys\"},{\"phone\":\"121\",\"name\":\"My Idea\"},{\"phone\":\"9606721137\",\"name\":\"Shasi Indbulls\"},{\"phone\":\"9110205767\",\"name\":\"Swathi Blke\"},{\"phone\":\"73489 10967\",\"name\":\"Suheal\"},{\"phone\":\" 78921 20101\",\"name\":\"Arun Pk\"},{\"phone\":\"9353368678\",\"name\":\"Manja Hs\"},{\"phone\":\" 93533 68678\",\"name\":\"Manja Hs\"},{\"phone\":\"9066221062\",\"name\":\"Appaji What's Num\"},{\"phone\":\" 88925 83450\",\"name\":\"Prasanna Bouncer\"},{\"phone\":\" 78924 38926\",\"name\":\"Yogedra\"},{\"phone\":\"6360140173\",\"name\":\"In focus barath\"},{\"phone\":\"8050284727\",\"name\":\"Demanth Inb\"},{\"phone\":\"9113218365\",\"name\":\"Rajesh Krezybee\"},{\"phone\":\"7349673367\",\"name\":\"Rajini\"},{\"phone\":\"8722363003\",\"name\":\"Chethannn Gym\"},{\"phone\":\"101\",\"name\":\"fire\"},{\"phone\":\"9008181503\",\"name\":\"Shasi Boncer\"},{\"phone\":\"9353153028\",\"name\":\"Sunil Tamdi\"},{\"phone\":\"9036099316\",\"name\":\"Sudhakaran Bng Mgr\"},{\"phone\":\"8147343924\",\"name\":\"Bouncer Chethan\"},{\"phone\":\"9066427048\",\"name\":\"LOKESH\"},{\"phone\":\"9686061849\",\"name\":\"Punyaka\"},{\"phone\":\" 93531 14191\",\"name\":\"Sushma HKpsy\"},{\"phone\":\"9113848399\",\"name\":\"Ravi Inb 2\"},{\"phone\":\"9945217482\",\"name\":\"Ln\"},{\"phone\":\"8095709482\",\"name\":\"Chandu devarahalli\"},{\"phone\":\"97404 20182\",\"name\":\"Bouncer Gunda Mys\"},{\"phone\":\"7204721669\",\"name\":\"Sruthi Wg\"},{\"phone\":\"72598 98707\",\"name\":\"Prashanth bai\"},{\"phone\":\"8123596966\",\"name\":\"Dhanu Bncr\"},{\"phone\":\"9743996339\",\"name\":\"Arun Sir Indbulls\"},{\"phone\":\"9110217050\",\"name\":\"Dr Hiremath\"},{\"phone\":\"9538822002\",\"name\":\"AKS B\"},{\"phone\":\"9738652890\",\"name\":\"SANJU\"},{\"phone\":\"9353114191\",\"name\":\"Sushma HKpsy\"},{\"phone\":\"90353 36060\",\"name\":\"Colleg Kn\"},{\"phone\":\"9036099347\",\"name\":\"Sharath Sir Inb\"},{\"phone\":\" 70260 84063\",\"name\":\"Lossssss\"},{\"phone\":\"7829561828\",\"name\":\"Sudha Maa\"},{\"phone\":\"8971798147\",\"name\":\"Navanitha\"},{\"phone\":\"7892438926\",\"name\":\"Yogedra\"},{\"phone\":\"90666 66867\",\"name\":\"Prashu Print\"},{\"phone\":\"56789\",\"name\":\"Dialer Tone\"},{\"phone\":\"9742792540\",\"name\":\"Dad\"},{\"phone\":\" 81235 96966\",\"name\":\"Dhanu Bncr\"},{\"phone\":\" 97396 28815\",\"name\":\"Suvash Bouncer\"},{\"phone\":\"9449383094\",\"name\":\"Ragava Mc M\"},{\"phone\":\"7090045572\",\"name\":\"Akki Sanjor\"},{\"phone\":\"8310923418\",\"name\":\"Shathis Blk D\"},{\"phone\":\"8553411474\",\"name\":\"Ravi Rajan Indbull\"},{\"phone\":\"76249 51495\",\"name\":\"Chandu Dvl\"},{\"phone\":\"6361233393\",\"name\":\"Gowthu Mcm Raghu\"},{\"phone\":\"7090838823\",\"name\":\"Sandeepa\"},{\"phone\":\"9739707338\",\"name\":\"Hp\"},{\"phone\":\"7892841997\",\"name\":\"Gowthu2\"},{\"phone\":\"9945873431\",\"name\":\"Manoj m\"},{\"phone\":\"8970555193\",\"name\":\"sudeep f\"},{\"phone\":\"90365 98175\",\"name\":\"Suraj Divya Pk\"},{\"phone\":\"7348907735\",\"name\":\"Sudeep Mahadev\"},{\"phone\":\" 90196 58836\",\"name\":\"Priya S\"},{\"phone\":\"9902359359\",\"name\":\"Naveen Arginesar\"},{\"phone\":\"8151961790\",\"name\":\"Krish c\"},{\"phone\":\"9110659585\",\"name\":\"Harsha Bouncer\"},{\"phone\":\"9148745373\",\"name\":\"Hemanth Bk\"},{\"phone\":\"9632988125\",\"name\":\"Thunga Mys\"},{\"phone\":\"8310653295\",\"name\":\"Manu Bouncer\"},{\"phone\":\"8073694906\",\"name\":\"Bouncer Venki Mys\"},{\"phone\":\" 81236 56571\",\"name\":\"Harsha Indb\"},{\"phone\":\"9066903148\",\"name\":\"Chandhu Chethu\"},{\"phone\":\"70262 64636\",\"name\":\"Kiran Mcm d\"},{\"phone\":\" 63616 87262\",\"name\":\"Sijini Iifl\"},{\"phone\":\"98861 31610\",\"name\":\"Delipbai Koplu 2\"},{\"phone\":\"9901626756\",\"name\":\"Sp\"},{\"phone\":\"9341156665\",\"name\":\"Aryan\"},{\"phone\":\"8088476009\",\"name\":\"Madhu Bouncer Mys\"},{\"phone\":\"8217634736\",\"name\":\"Hari Praju\"},{\"phone\":\"9738406284\",\"name\":\"Nagesh police\"},{\"phone\":\"9538404680\",\"name\":\"Sagar m 2\"},{\"phone\":\"9886860634\",\"name\":\"Kumar mava Htgl\"},{\"phone\":\"9986029150\",\"name\":\"Yashu Pks\"},{\"phone\":\"8971095950\",\"name\":\"Shilpa Evtt\"},{\"phone\":\"8722187070\",\"name\":\"India Bulls Hr\"},{\"phone\":\"9740764548\",\"name\":\"9740764548 64548\"},{\"phone\":\" 97439 96339\",\"name\":\"Arun Sir Indbulls\"},{\"phone\":\"6360435211\",\"name\":\"Karna Yogi\"},{\"phone\":\"7406372577\",\"name\":\"Suman Mcm\"},{\"phone\":\"8217458084\",\"name\":\"Sagar duke\"},{\"phone\":\"6364020574\",\"name\":\"Lokesh Raj Rq\"},{\"phone\":\" 96868 43112\",\"name\":\"Manu Bncr\"},{\"phone\":\"7353856510\",\"name\":\"Prajwal\"},{\"phone\":\"8123656571\",\"name\":\"Harsha Indb\"},{\"phone\":\"9535003364\",\"name\":\"Sanju Ma\"},{\"phone\":\"9341655094\",\"name\":\"Ganesh 2\"},{\"phone\":\"7483911846\",\"name\":\"Benki Madhev\"},{\"phone\":\"7619621279\",\"name\":\"Yashwant Blk\"},{\"phone\":\"6361687262\",\"name\":\"Sijini Iifl\"},{\"phone\":\"88616 35663\",\"name\":\"Surabhi Cosin\"},{\"phone\":\"6203292971\",\"name\":\"Priya Cg\"},{\"phone\":\" 63642 79594\",\"name\":\"Prashana 2\"},{\"phone\":\"9611502136\",\"name\":\"Rakesh Bogadhi\"},{\"phone\":\"8496901934\",\"name\":\"Manohar M M C\"},{\"phone\":\"7483234639\",\"name\":\"Shivu\"},{\"phone\":\"7899663071\",\"name\":\"Kiran Bouncer\"},{\"phone\":\"8105717457\",\"name\":\"Ananda 2\"},{\"phone\":\"9066313198\",\"name\":\"Samarth Bouncer\"},{\"phone\":\"9818752418\",\"name\":\"C Kanika\"},{\"phone\":\" 81056 09054\",\"name\":\"Bncr Gunda Mys Prm\"},{\"phone\":\"9886884194\",\"name\":\"Suri Mmc\"},{\"phone\":\"8951734980\",\"name\":\"Bouncer Sanmuka Mys\"},{\"phone\":\"8971775116\",\"name\":\"Hemanth Haveri Stg\"},{\"phone\":\" 80736 94906\",\"name\":\"Bouncer Venki Mys\"},{\"phone\":\"9110295842\",\"name\":\"Yashwanth Benglore\"},{\"name\":\"Ganesh Dll\"},{\"phone\":\"8553468017\",\"name\":\"Abi koti\"},{\"phone\":\"100\",\"name\":\"Police\"},{\"phone\":\"139\",\"name\":\"railway inquiry\"},{\"phone\":\" 81476 11884\",\"name\":\"Usha Hr\"},{\"phone\":\"7090054944\",\"name\":\"Mys Suma\"},{\"phone\":\"8892660745\",\"name\":\"Krishna Mcm\"},{\"phone\":\"121\",\"name\":\"customer care\"},{\"phone\":\"6363589212\",\"name\":\"Ravi Kiran\"},{\"phone\":\" 86607 30081\",\"name\":\"Harsha\"},{\"phone\":\"7349242447\",\"name\":\"Sudhama\"},{\"phone\":\"8105548664\",\"name\":\"Sachi Mcm\"},{\"phone\":\"8892287730\",\"name\":\"Mudasir Bouncer\"},{\"phone\":\"8861635663\",\"name\":\"Surabhi Cosin\"},{\"phone\":\"9590471525\",\"name\":\"Anil Kumar sir\"},{\"phone\":\"9731053370\",\"name\":\"Shekar Drs\"},{\"phone\":\"63667 02721\",\"name\":\"Supritha\"},{\"phone\":\"84969 31345\",\"name\":\"Keb\"},{\"phone\":\"6364119140\",\"name\":\"Puni Dangalli\"},{\"phone\":\"8660730081\",\"name\":\"Harsha\"},{\"phone\":\"85534 11474\",\"name\":\"Ravi Rajan Indbull\"},{\"phone\":\"6364214426\",\"name\":\"Deepu Blk\"},{\"phone\":\"96115 39220\",\"name\":\"Seike Aff\"},{\"phone\":\"9980937657\",\"name\":\"Lankesh Praju\"},{\"phone\":\"8971838093\",\"name\":\"Ambu Ambu Mys\"},{\"phone\":\"9945113426\",\"name\":\"Mahadev Benki\"},{\"phone\":\"7899126949\",\"name\":\"Yogesh Tv\"},{\"phone\":\"18002089898\",\"name\":\"Watch\"},{\"phone\":\" 94488 28430\",\"name\":\"Dj Presley\"},{\"phone\":\"7026994555\",\"name\":\"Gani B R\"},{\"phone\":\"9900421611\",\"name\":\"Sudeep Sisya\"},{\"phone\":\"54445\",\"name\":\"doctor on call\"},{\"phone\":\"9663707389\",\"name\":\"Bad Boy\"},{\"phone\":\"7019883529\",\"name\":\"Nanjundswamy Rbl\"},{\"phone\":\"8496931345\",\"name\":\"Keb\"},{\"phone\":\"7090737305\",\"name\":\"Yagi Loose\"},{\"phone\":\"9740097057\",\"name\":\"Ravi anna\"},{\"phone\":\" 95356 22873\",\"name\":\"Prashanth\"},{\"phone\":\" 96115 02136\",\"name\":\"Rakesh Bogadhi\"},{\"phone\":\"9740174104\",\"name\":\"Vinod Bk\"},{\"phone\":\"7996943163\",\"name\":\"Putt Mava\"},{\"phone\":\"8892044219\",\"name\":\"Gowthu\"},{\"phone\":\" 87924 42729\",\"name\":\"Surya Tony Pk\"},{\"phone\":\"7406048295\",\"name\":\"Vipul m\"},{\"phone\":\"8618720447\",\"name\":\"Kumar appaji\"},{\"phone\":\"8496950869\",\"name\":\"Hari Hsn\"},{\"phone\":\"82776 15736\",\"name\":\"Unath Pk 2\"},{\"phone\":\"74115 67682\",\"name\":\"Anusha Mys\"},{\"phone\":\"9538582552\",\"name\":\"Punith B\"},{\"phone\":\"543212601\",\"name\":\"AL cricket\"},{\"phone\":\"6361 418 440\",\"name\":\"Praju Bro\"},{\"phone\":\"9110821159\",\"name\":\"Anil Bouncer Mys\"},{\"phone\":\"78929 84190\",\"name\":\"Sena Bilikere\"},{\"phone\":\"9353406778\",\"name\":\"Credit\"},{\"phone\":\" 70222 44605\",\"name\":\"Sanju Ilv\"},{\"phone\":\"7899007621\",\"name\":\"Kartik Bouncer Mys\"},{\"phone\":\"8892583450\",\"name\":\"Prasanna Bouncer\"},{\"phone\":\" 99860 29150\",\"name\":\"Yashu Pks\"},{\"phone\":\" 74832 34639\",\"name\":\"Shivu\"},{\"phone\":\"9880797568\",\"name\":\"Jammuuu\"},{\"phone\":\" 63635 99943\",\"name\":\"Chaitanya Checkp\"},{\"phone\":\"8151934533\",\"name\":\"Venki Ycm\"},{\"phone\":\"9164498877\",\"name\":\"H m r\"},{\"phone\":\" 97401 74104\",\"name\":\"Vinod Bk\"},{\"phone\":\"89517 34980\",\"name\":\"Bouncer Sanmuka Mys\"},{\"phone\":\"734 902 6816\",\"name\":\"Darshan Soppu\"},{\"phone\":\"1977\",\"name\":\"Jio-Tele-verification Helpline\"},{\"phone\":\"9686843112\",\"name\":\"Manu Bncr\"},{\"phone\":\"6361418440\",\"name\":\"Praju Bro\"},{\"phone\":\"6363609192\",\"name\":\"Viggi 2\"},{\"phone\":\"9901547426\",\"name\":\"C Sneha\"},{\"phone\":\"85537 09297\",\"name\":\"Puttu Bro\"},{\"phone\":\"9740420182\",\"name\":\"Bouncer Gunda Mys\"},{\"phone\":\"99642 30975\",\"name\":\"Karna2 Yogi\"},{\"phone\":\"8496008854\",\"name\":\"Puni2\"},{\"phone\":\"8749012422\",\"name\":\"Sathish Inb\"},{\"phone\":\"8527355100\",\"name\":\"emergency alert\"},{\"phone\":\"7975660885\",\"name\":\"Karti Mys Mn\"},{\"phone\":\"8151892833\",\"name\":\"Navina Mcm\"},{\"phone\":\"9632974642\",\"name\":\"Chikappa Rtl\"},{\"phone\":\" 81508 36986\",\"name\":\"Macha\"},{\"phone\":\"9035239272\",\"name\":\"Arpitha M Y\"},{\"phone\":\"8095614124\",\"name\":\"Punith Raj Gandhi\"},{\"phone\":\"7975027354\",\"name\":\"7975027354\"},{\"phone\":\" 76590 83214\",\"name\":\"Przlee\"},{\"phone\":\" 73530 53367\",\"name\":\"Vishwa Vvet\"},{\"phone\":\"8546927496\",\"name\":\"Yatapa\"},{\"phone\":\"8217577608\",\"name\":\"Anandh Ibs\"},{\"phone\":\" 76196 21279\",\"name\":\"Yashwant Blk\"},{\"phone\":\"7892155345\",\"name\":\"Mohan Friend\"},{\"phone\":\"8971391139\",\"name\":\"Mahadhev Ms\"},{\"phone\":\"8310269785\",\"name\":\"Putta Raju Jinalli\"},{\"phone\":\"7892156869\",\"name\":\"Lavish\"},{\"phone\":\"9538248016\",\"name\":\"Boncer Alif Mys\"},{\"phone\":\"8105685386\",\"name\":\"Deepu Krn\"},{\"phone\":\"8971402128\",\"name\":\"Swathi kothi\"},{\"phone\":\" 88611 12302\",\"name\":\"Prathap Gym\"},{\"phone\":\"866 050 8344\",\"name\":\"Dheshpremi\"},{\"phone\":\"7975408051\",\"name\":\"Raj\"},{\"phone\":\"8088068015\",\"name\":\"Unath Pk\"},{\"phone\":\"9739276897\",\"name\":\"Yogi Blk Ml\"},{\"phone\":\"7892956859\",\"name\":\"Kiran Bp\"},{\"phone\":\"12131\",\"name\":\"my offer\"},{\"phone\":\"8867614303\",\"name\":\"Prashana Bouncer\"},{\"phone\":\"9901243411\",\"name\":\"Rajashekar Hsli\"},{\"phone\":\" 90357 99096\",\"name\":\"Abhishek Narayan\"},{\"phone\":\" 70269 74062\",\"name\":\"Srinivas 2 Blk\"},{\"phone\":\"9741411113\",\"name\":\"Prashu\"},{\"phone\":\"7026576635\",\"name\":\"Rajesh mulangi\"},{\"phone\":\"9964487466\",\"name\":\"Lingaraj Uncle S\"},{\"phone\":\"9483539094\",\"name\":\"Raagu m\"},{\"phone\":\" 91487 45373\",\"name\":\"Hemanth Bk\"},{\"phone\":\"9066666867\",\"name\":\"Prashu Print\"},{\"phone\":\"8548050042\",\"name\":\"ravi chinnu\"},{\"phone\":\" 96065 26019\",\"name\":\"Sagar Ilv\"},{\"phone\":\"7892045572\",\"name\":\"Mahesh Sanga\"},{\"phone\":\"6363674729\",\"name\":\"Sanju Shooting\"},{\"phone\":\"8217739921\",\"name\":\"Madana Jio\"},{\"phone\":\"9845321713\",\"name\":\"Nf\"},{\"phone\":\"12345\",\"name\":\"Customer Care\"},{\"phone\":\"9900389277\",\"name\":\"Kishan\"},{\"phone\":\"7975027354\",\"name\":\"7975027354 27354\"},{\"phone\":\" 88840 60130\",\"name\":\"Vinay Gym\"},{\"phone\":\"7338513527\",\"name\":\"Vaibavi\"},{\"phone\":\"9738712073\",\"name\":\"Sanju Bro Boncer Bng\"},{\"phone\":\"8892923338\",\"name\":\"Sreyesh Mcm\"},{\"phone\":\"543212\",\"name\":\"AL entertainment\"},{\"phone\":\"9591906041\",\"name\":\"Chethu Lap\"},{\"phone\":\"100\",\"name\":\"police\"},{\"phone\":\"8884060130\",\"name\":\"Vinay Gym\"},{\"phone\":\"9036598175\",\"name\":\"Suraj Divya Pk\"},{\"phone\":\"81059 02128\",\"name\":\"Pursotham Mys\"},{\"phone\":\"9611539220\",\"name\":\"Seike Aff\"},{\"phone\":\"97392 11351\",\"name\":\"Boncer Manoj Rh2\"},{\"phone\":\"9741092893\",\"name\":\"Rahul Ab\"},{\"phone\":\"6363227139\",\"name\":\"Harsha Blk2\"},{\"phone\":\"7259898707\",\"name\":\"Prashanth bai\"},{\"phone\":\"9739211351\",\"name\":\"Boncer Manoj Rh2\"},{\"phone\":\"9901043108\",\"name\":\"Manu M\"},{\"phone\":\"9916522223\",\"name\":\"Rajini\"},{\"phone\":\"8748888755\",\"name\":\"Anil Sir\"},{\"phone\":\"8747952003\",\"name\":\"Bukki Bashkar\"},{\"phone\":\"8123656571\",\"name\":\"Harsha Indbl\"},{\"phone\":\"7411457721\",\"name\":\"Appajiii\"},{\"phone\":\"9980433253\",\"name\":\"Prashi Bro Bnsr\"},{\"phone\":\"7026868278\",\"name\":\"Pavan Bouncer\"},{\"phone\":\"543211\",\"name\":\"AL hello tunes\"},{\"phone\":\"8147611884\",\"name\":\"Usha Hr\"},{\"phone\":\" 88671 03260\",\"name\":\"Madhu Mys\"},{\"phone\":\"8150836986\",\"name\":\"Macha\"},{\"phone\":\"9743996339\",\"name\":\"Arun Sir Yogi\"},{\"phone\":\"8951095148\",\"name\":\"Sagar M\"},{\"phone\":\"9036944962\",\"name\":\"Akshay K R S\"},{\"phone\":\" 73496 73367\",\"name\":\"Rajini\"},{\"phone\":\"7026974062\",\"name\":\"Srinivas 2 Blk\"},{\"phone\":\"9738637596\",\"name\":\"+919738637596\"},{\"phone\":\"9902849119\",\"name\":\"A\"},{\"phone\":\"9611161111\",\"name\":\"Harsha Sir Mys\"},{\"phone\":\"9448743988\",\"name\":\"Harshi Mcm\"},{\"phone\":\"8073389870\",\"name\":\"Anil Inb Blk\"},{\"phone\":\"9663737445\",\"name\":\"Bncr Nagendra Bnlr\"},{\"phone\":\"9632163514\",\"name\":\"Vasu\"},{\"phone\":\"81971 15296\",\"name\":\"Jai Kumar\"},{\"phone\":\" 63633 51404\",\"name\":\"Sathya 2\"},{\"phone\":\" 82175 77608\",\"name\":\"Anandh Ibs\"},{\"phone\":\" 99010 44391\",\"name\":\"Mahesh Babu\"},{\"phone\":\"7760859019\",\"name\":\"Chethu Ratnalli\"},{\"phone\":\"8152938533\",\"name\":\"Kirana Ettha\"},{\"phone\":\"7204726714\",\"name\":\"Aki sanjor\"},{\"phone\":\"9902922173\",\"name\":\"Santhu polord\"},{\"phone\":\"7349673272\",\"name\":\"Santhu\"},{\"phone\":\" 88616 94949\",\"name\":\"Chandhu Patel\"},{\"phone\":\"9886131610\",\"name\":\"Delipbai Koplu 2\"},{\"phone\":\"9901044391\",\"name\":\"Mahesh Babu\"},{\"phone\":\"7090045572\",\"name\":\"AkhiSanjor\"},{\"phone\":\"70267 95118\",\"name\":\"Chandu Karthi\"},{\"phone\":\"9591764631\",\"name\":\"Pramu Airtel\"},{\"phone\":\"77608 59019\",\"name\":\"Chethu Ratnalli\"},{\"phone\":\"8495028187\",\"name\":\"Abc\"},{\"phone\":\"9964393564\",\"name\":\"Sangeetha\"},{\"phone\":\"*121#\",\"name\":\"My Best Offer\"},{\"phone\":\"7026189754\",\"name\":\"Sunil s/o Shesa\"},{\"phone\":\"8792398929\",\"name\":\"Bouncer Harish Kesare\"},{\"phone\":\"9986114571\",\"name\":\"Kavya Cg\"},{\"phone\":\" 89705 05292\",\"name\":\"Tanzim Mcm\"},{\"phone\":\"8474080442\",\"name\":\"Baratha m\"},{\"phone\":\"9591907152\",\"name\":\"Sannu venki\"},{\"phone\":\"8494822608\",\"name\":\"Madhu Shekar\"},{\"phone\":\"8660352551\",\"name\":\"Vipul\"},{\"phone\":\"9148745373\",\"name\":\"Hemanth Bk\"},{\"phone\":\"7026701477\",\"name\":\"Bebi\"},{\"phone\":\"861 891 1495\",\"name\":\"Sudha Chikki\"},{\"phone\":\" 84969 50869\",\"name\":\"Hari Hsn\"},{\"phone\":\"8549903833\",\"name\":\"Vasu 2\"},{\"phone\":\"139\",\"name\":\"Railways\"},{\"phone\":\"95382 48016\",\"name\":\"Boncer Alif Mys\"},{\"phone\":\"7892984817\",\"name\":\"Murali Sir Inb\"},{\"phone\":\" 63632 27139\",\"name\":\"Harsha Blk2\"},{\"phone\":\"139\",\"name\":\"Rail Enquiry\"},{\"phone\":\"7019053698\",\"name\":\"Gowthu Bouncer\"},{\"phone\":\"9148740172\",\"name\":\"Rakey Puram\"},{\"phone\":\"*191#\",\"name\":\"Know Your Plan\"},{\"phone\":\" 99644 87466\",\"name\":\"Lingaraj Uncle S\"},{\"phone\":\"9164141137\",\"name\":\"Chethu Y\"},{\"phone\":\" 98459 24797\",\"name\":\"Pallavi Bngl\"},{\"phone\":\"8951667099\",\"name\":\"Raj Mava\"},{\"phone\":\"9743732171\",\"name\":\"Pradi kolli\"},{\"phone\":\"9739340816\",\"name\":\"Pooja fb\"},{\"phone\":\"8277615736\",\"name\":\"Unath Pk 2\"},{\"phone\":\"8792206391\",\"name\":\"Anandha\"},{\"phone\":\"8660239799\",\"name\":\"Swagath Hdfc\"},{\"phone\":\"8660508344\",\"name\":\"Dheshpremi\"},{\"phone\":\"9742360589\",\"name\":\"Hari Bouncer\"},{\"phone\":\"199\",\"name\":\"Jio-General Helpline\"},{\"phone\":\"9008300555\",\"name\":\"Nandhish Nnl\"},{\"name\":\"Thata\"},{\"phone\":\"7353863214\",\"name\":\"Chethanya Checkp\"}]}";

            DeviceContactDataVO contactByList = getContactByList(content, "1111");
            System.err.println(111);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static DeviceContactDataVO getContactByList(String content, String mobile) throws Exception {
        List<DeviceContactVO> riskDeviceContactList = new ArrayList<>();
        List<DeviceContactVO> relativeContactList = new ArrayList<>();

        DeviceContactDataVO data = JSONUtils.json2pojo(content, DeviceContactDataVO.class);
        if (data.getContacts() != null) {
            //号码格式处理
            for (DeviceContactVO vo : data.getContacts()) {
                if (StringUtils.isNotEmpty(vo.getPhone())) {
                    vo.setPhone(IndiaMobileUtil.countryCodeFilter(vo.getPhone()));
                }
            }
            //去重
            data.setContacts(distinctContactList(data.getContacts()));

            data.setTotalNum(data.getContacts().size());
            for (DeviceContactVO contact : data.getContacts()) {
                if (StringUtils.isEmpty(contact.getPhone())) {
                    continue;
                }

                if (null != contact.getPhone() && contact.getPhone().contains("-")) {
                    contact.setPhone(contact.getPhone().replaceAll("-", "").replace(" ", ""));
                    if (contact.getPhone().startsWith("+91")) {
                        contact.setPhone(contact.getPhone().substring(3));
                    }

                    if (!StringUtils.isEmpty(mobile) && contact.getPhone().contains(mobile)) {
                        contact.setRed(true);
                        data.setContactHitApplyMobile(true);
                        data.setContactApplyMobileName(contact.getName());
                    }

                }
                contact.setLastTimeContacted(contact.getLastTimeContacted());
                contact.setLastTimeContactedStr(toDateString(contact.getLastTimeContacted()));
                if (null != contact.getName()) {
                    setDeviceContact(data, contact, riskDeviceContactList, relativeContactList);
                }
            }
        }
        if (data.getCalls() != null) {
            for (DeviceCallVO call : data.getCalls()) {
                call.setCallTime(call.getCallTime());
                call.setCallTimeStr(toDateString(call.getCallTime()));
            }
        }
        List<DeviceContactVO> deviceContactList = data.getContacts();
        riskDeviceContactList.addAll(relativeContactList);
        riskDeviceContactList.addAll(deviceContactList);
        data.setContacts(riskDeviceContactList);
        return data;
    }

    private static void setDeviceContact(DeviceContactDataVO data, DeviceContactVO DeviceContactVO, List<DeviceContactVO> riskDeviceContactList, List<DeviceContactVO> relativeContactList) {
        String deviceContactName = StringUtils.isEmpty(DeviceContactVO.getName()) ? "" : DeviceContactVO.getName().toLowerCase();
        if (deviceContactName.contains("loan") || deviceContactName.contains("loans") ||
                deviceContactName.contains("personal loans") ||
                deviceContactName.contains("finance") || deviceContactName.contains("emi")
                || deviceContactName.contains("cibil") || deviceContactName.contains("cash")
                || deviceContactName.contains("payday") || deviceContactName.contains("lend")
                || deviceContactName.contains("lengding") || deviceContactName.contains("borrow")
                || deviceContactName.contains("borrowing") || deviceContactName.contains("money")
        ) {
            data.setRiskNum(data.getRiskNum() + 1);
            DeviceContactVO.setDeviceType(2);//异常
            riskDeviceContactList.add(DeviceContactVO);
        } else if (deviceContactName.contains("daddy") || deviceContactName.contains("pa")
                || deviceContactName.contains("nana") || deviceContactName.contains("nanna")
                || deviceContactName.contains("pitaji") || deviceContactName.contains("dada")
                || deviceContactName.contains("appa") || deviceContactName.contains("tande")
                || deviceContactName.contains("dad") || deviceContactName.contains("father")
                || deviceContactName.contains("mother") || deviceContactName.contains("ma")
                || deviceContactName.contains("aai") || deviceContactName.contains("taie")
                || deviceContactName.contains("mom") || deviceContactName.contains("mommy")
                || deviceContactName.contains("tammudu") || deviceContactName.contains("brother")
                || deviceContactName.contains("tamma") || deviceContactName.contains("bhaiya")
                || deviceContactName.contains("di") || deviceContactName.contains("sister")
                || deviceContactName.contains("tangi") || deviceContactName.contains("akka")
                || deviceContactName.contains("tai") || deviceContactName.contains("chelli")
                || deviceContactName.contains("behen") || deviceContactName.contains("husband")
                || deviceContactName.contains("mogudu") || deviceContactName.contains("pati")
                || deviceContactName.contains("navra") || deviceContactName.contains("virji")
                || deviceContactName.contains("gandaa") || deviceContactName.contains("navardev")
                || deviceContactName.contains("hubby") || deviceContactName.contains("wife")
                || deviceContactName.contains("pellam") || deviceContactName.contains("navri")
                || deviceContactName.contains("pellam") || deviceContactName.contains("navri")
                || deviceContactName.contains("biwi") || deviceContactName.contains("hendthi")
                || deviceContactName.contains("patni") || deviceContactName.contains("son")
                || deviceContactName.contains("beta") || deviceContactName.contains("koduku")
                || deviceContactName.contains("maga") || deviceContactName.contains("daughter")
                || deviceContactName.contains("beti") || deviceContactName.contains("kuthuru")
                || deviceContactName.contains("grandmother") || deviceContactName.contains("aaji")
                || deviceContactName.contains("dadima") || deviceContactName.contains("ammama")
                || deviceContactName.contains("aai") || deviceContactName.contains("nainamma")
                || deviceContactName.contains("grandma") || deviceContactName.contains("granny")
                || deviceContactName.contains("nana") || deviceContactName.contains("grandfather")
                || deviceContactName.contains("dadaji") || deviceContactName.contains("tatha")
                || deviceContactName.contains("aaja") || deviceContactName.contains("aajoba")
                || deviceContactName.contains("tatya") || deviceContactName.contains("grandad")
                || deviceContactName.contains("grandpa") || deviceContactName.contains("uncle")
                || deviceContactName.contains("kaka") || deviceContactName.contains("chednaina")
                || deviceContactName.contains("babai") || deviceContactName.contains("pednaina")
                || deviceContactName.contains("aunt") || deviceContactName.contains("mami")
                || deviceContactName.contains("kaku") || deviceContactName.contains("chinnaina")
                || deviceContactName.contains("pinni") || deviceContactName.contains("chinnama")
                || deviceContactName.contains("nephew") || deviceContactName.contains("putnya")
                || deviceContactName.contains("aaldiya") || deviceContactName.contains("alludu")
                || deviceContactName.contains("bawa") || deviceContactName.contains("neice")
                || deviceContactName.contains("cousin") || deviceContactName.contains("sister-in-law")
                || deviceContactName.contains("father-in-law") || deviceContactName.contains("mother-in-law")
                || deviceContactName.contains("daughter-in-law") || deviceContactName.contains("stepmother")
                || deviceContactName.contains("stepfather") || deviceContactName.contains("stepson")
                || deviceContactName.contains("stepdaughter") || deviceContactName.contains("half-brother")
                || deviceContactName.contains("half-sister") || deviceContactName.contains("grandson")
                || deviceContactName.contains("granddaughter") || deviceContactName.contains("great-grandson")
                || deviceContactName.contains("adopted son") || deviceContactName.contains("adopted daughter")
                || deviceContactName.contains("honey") || deviceContactName.contains("sweetheart")
                || deviceContactName.contains("baby") || deviceContactName.contains("darling")
                || deviceContactName.contains("little princess") || deviceContactName.contains("princess")
                || deviceContactName.contains("bhai")) {
            data.setRelativeNum(data.getRelativeNum() + 1);
            DeviceContactVO.setDeviceType(1);//亲戚
            relativeContactList.add(DeviceContactVO);
        } else {
            DeviceContactVO.setDeviceType(0);
        }
    }

    private static String toDateString(String time) {
        if (StringUtils.isEmpty(time) || time.length() <= 4) {
            return "";
        }
        Date date = null;
        if (time.contains("-")) {
            date = DateUtil.getDate(time, "yyyy-MM-dd HH:mm:ss");
        } else {
            date = new Date(Long.parseLong(time));
        }

        return DateUtil.getDate(date, "yyyy-MM-dd HH:mm:ss");
    }

    private static List<DeviceContactVO> distinctContactList(List<DeviceContactVO> contactList) {
        if (CollectionUtils.isEmpty(contactList)) {
            return new ArrayList<>();
        }
        return contactList.stream().filter(item -> IndiaMobileUtil.isMobileNumber(item.getPhone())).collect(
                Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getName() + "_" + o.getPhone()))),
                        ArrayList::new));
    }
}
